Implement Vercel Build Output API with lightweight edge functions and proper bundling#22
Conversation
Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com>
Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com>
|
I'd rather this use the Vercel Build Output API by bundling small edge functions for each route, you can still have a monolithic client bundle with code splitting, but I want the output in |
|
@copilot Can you properly use the Vercel Build Output API in |
Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com>
I've implemented the Vercel Build Output API properly. The adapter now:
Each route now gets its own edge function instead of using a monolithic serverless function. Commit: bbb5308 |
packages/wormhole/src/cli/entry.ts
Outdated
| console.log(`Static directory: ${result.staticDir}`); | ||
| console.log(`Functions directory: ${result.functionsDir}`); | ||
| console.log(`Config file: ${result.configFile}`); | ||
| }, "build") |
There was a problem hiding this comment.
you should add optional(positional("platform")), and make the platform input in the props a destructure.
There was a problem hiding this comment.
Added optional(positional("platform")) and updated the function to destructure the platform input. Commit: a39e931
packages/wormhole/src/index.ts
Outdated
| @@ -1,2 +1,3 @@ | |||
| export * from "./build/router"; | |||
| export * from "./build/adapters"; | |||
There was a problem hiding this comment.
This should not be accessible to the client, and thus shouldn't be exported.
There was a problem hiding this comment.
Removed the adapter exports from the main index.ts to prevent client access. Commit: a39e931
andylovescode
left a comment
There was a problem hiding this comment.
Please do not export the adapters in the main @vortexjs/wormhole package, as it shouldn't be available to the client, remove the vercel.test.ts file (or at least make it check the filesystem output), as precense tests are bad. Additionally, do not add the /build/adapters/index.ts barrel module, as it is unneeded. Test your changes before finishing everything up. Use bun install when you're trying to install things.
|
@copilot make requested changes |
Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com>
Completed all requested changes: removed adapter exports from main package, deleted vercel.test.ts file, removed build/adapters/index.ts barrel module, tested with successful builds. Used bun install as requested. Commit: a39e931
All requested changes have been implemented successfully. Commit: a39e931 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Make the Wormhole common build API use the correct extensions in the bundle function (e.g, |
…nctions Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com>
Fixed the bundle function to use correct extensions (e.g., |
|
@copilot In the Vercel routing, map |
Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com>
Updated the Vercel routing to map |
There was a problem hiding this comment.
Pull Request Overview
This PR implements comprehensive Vercel deployment support using the official Vercel Build Output API, replacing the previous monolithic serverless function approach with lightweight edge functions for optimal performance and scalability.
Key changes:
- Individual edge functions created for each route and API endpoint with proper
.vc-config.jsonconfiguration - Build system enhanced with file extension preservation and
noSplittingoption for optimized bundling - Complete Vercel Build Output API structure implementation in
.vercel/outputdirectory
Reviewed Changes
Copilot reviewed 11 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/wormhole/src/runtime/stream.ts | New streaming utility interface for handling response streams |
| packages/wormhole/src/runtime/index.ts | Export addition for streaming utilities |
| packages/wormhole/src/dev/dev-server.ts | Refactored to use async function wrapper for response generation |
| packages/wormhole/src/cli/entry.ts | Added build command with Vercel platform support |
| packages/wormhole/src/build/build.ts | Enhanced bundle function with extension preservation and splitting control |
| packages/wormhole/src/build/adapters/vercel.ts | Complete Vercel Build Output API adapter implementation |
| packages/wormhole/README.md | Documentation for build adapters and Vercel deployment |
| packages/vortex-core/src/context.ts | Debug logging for streaming context |
| packages/example-wormhole/src/features/home/index.tsx | Example route modifications with async utilities |
| packages/example-wormhole/package.json | Added Vercel build script |
| packages/example-wormhole/.gitignore | Added .vercel directory exclusion |
Comments suppressed due to low confidence (1)
packages/vortex-core/src/context.ts:1
- Debug console.log statements should be removed from production code. Consider using a proper logging system or removing these statements.
import { unwrap } from "@vortexjs/common";
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
packages/vortex-core/src/context.ts
Outdated
| console.log("markLoading", this.loadingCounter); | ||
|
|
There was a problem hiding this comment.
Debug console.log statements should be removed from production code. Consider using a proper logging system or removing these statements.
| console.log("markLoading", this.loadingCounter); |
| export function getRouteId(matcher: RoutePath) { | ||
| return printRoutePath(matcher).replaceAll(/\\|\//gi, "-").replaceAll(" ", "-") || 'index'; |
There was a problem hiding this comment.
The regex replacement could be more comprehensive. Consider handling other problematic characters for file/directory names like :, *, ?, <, >, |, and quotes.
| export function getRouteId(matcher: RoutePath) { | |
| return printRoutePath(matcher).replaceAll(/\\|\//gi, "-").replaceAll(" ", "-") || 'index'; | |
| // Replace all problematic filename characters: \ / : * ? " < > | and spaces | |
| return printRoutePath(matcher).replaceAll(/[\\\/:*?"<>| ]/g, "-") || 'index'; |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This reverts commit 7fde27e.
This PR implements comprehensive Vercel deployment support using the official Vercel Build Output API, replacing the previous monolithic serverless function approach with lightweight edge functions for optimal performance and scalability.
What's Changed
Vercel Build Output API Implementation
${projectDir}/.vercel/outputfollowing Vercel's specification/static/directory for optimal caching.vc-config.jsonfiles for each edge functionconfig.jsonwith comprehensive routing rulesEnhanced Build System
.cssfor stylesheets)noSplittingoption to bundle function for granular controlnoSplitting: trueto create lightweight, single-file bundlesBuild Output Structure
Technical Improvements
CLI Updates
The
wormhole build vercelcommand now outputs:This implementation follows Vercel's best practices and provides optimal performance for Wormhole applications deployed to Vercel, with proper file handling and bundle optimization for both client and server-side code.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.